<template>
  <Layout>
    <Form ref="form1" :model="form1" :label-width="120">
      <Row class="query-form" style="padding-top: 15px">
        <Col span="8">
          <FormItem label="二级集团：">
            <two-level-org org-code class="query-form-el" v-model="form1.twoLevelOrgId"></two-level-org>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="被审计单位：">
            <!--            <cascaderDom ref="trainOrg" @setOrgInfo="setOrgId" @setOrgname="setOrgName"
                                     :currentOrgId="form1.orgId" :currentOrgName="form1.auditedOrgName" :orgTree="true" rootOrgId="18000000"></cascaderDom>-->
            <company-select v-model="form1.auditOrgName" class="query-form-el"></company-select>
          </FormItem>
        </Col>
        <Col span="8">
          <Button @click="reset" class="ivu-btn-reset">重置</Button>
          <Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
        </Col>
      </Row>

      <Row class="query-form">
        <Col span="24">
          <Button size="large" class="ivu-btn-add" icon="md-add" @click="addInfo">新增</Button>
        </Col>
      </Row>
    </Form>

    <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据！" :loading="buttonLoading" size="small"
           border :columns="columns1" :data="dataTable">
    </Table>
    <Row style="margin-right:10px;">
      <Col span="24">
        <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
              @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
              show-total show-sizer show-elevator/>
      </Col>
    </Row>

    <Modal :title="add?'提升方案新增':'提升方案修改'" :transfer=false v-model="model1" :width=600>
      <Row>
        <Col span="24">
          <Form ref="form1datacopy" :model="form1datacopy" :rules="ruleCustom" label-position="top">
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label="审计任务：" prop="missionId">
                  <Input v-model="form1datacopy.missionName" :readonly="true" @on-focus="openSelect"/>
                </FormItem>
              </Col>
            </Row>

            <Row type="flex" justify="space-around" class="code-row-bg">

              <Col span="23">
                <FormItem label="被审计单位：">
                  <Input v-model="form1datacopy.auditOrgName" :readonly="true"/>
                </FormItem>
              </Col>

            </Row>

            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label="概述：" >
                  <Input v-model="form1datacopy.desc" type="textarea" :rows="4"/>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label="上报人：" >
                  <Input v-model="form1datacopy.userName" :readonly="true" type="text"/>
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label="上报人电话：" prop="phone">
                  <Input v-model="form1datacopy.phone" type="text" />
                </FormItem>
              </Col>
            </Row>

            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label="提升方案：">
                  <div>
                    <Upload ref="upload"
                            :before-upload="beforeUpload"
                            :show-upload-list="true"
                            :max-size="10240"
                            multiple
                            type="drag"
                            :action="fileUrl">
                      <div style="padding: 10px">
                        <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                        <p>点击将文件拖拽到这里上传</p>
                        <span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>
                      </div>
                    </Upload>
                  </div>
                  <div v-show="uploadList.length>0" v-for="item in uploadList" :key='item'>
                    <a @click="downloadFile(form1datacopy.reportId,item)">{{ item.fileName }}</a>
                    <Button type="text" icon="md-trash" @click="remove1(item.id)"
                            style="margin-left: 5px;margin-bottom: 3px"/>
                  </div>
                </FormItem>
              </Col>
            </Row>
          </Form>
        </Col>
      </Row>
      <div slot="footer">
        <Button class='ivu-btn-save' @click="submit('form1datacopy')" :loading="buttonLoading1">确定</Button>
        <Button class='ivu-btn-cancel' @click="handleCancel">取消</Button>
      </div>
    </Modal>
    <Modal title="提升方案详情" v-model="model2" footer-hide class="modal-view-detail" :width=1000>

      <Form :model="form1datacopy" :label-width="160">
        <Row type="flex" justify="space-around">
          <Col span="23">
            <FormItem label="审计任务：" prop="stdOrgName">
              {{ form1datacopy.missionName }}
            </FormItem>
          </Col>

        </Row>

        <Row type="flex" justify="space-around">
          <Col span="23">
            <FormItem label="被审计单位：">
              {{ form1datacopy.auditOrgName }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="概述：">
              {{ form1datacopy.desc }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="上报人：">
              {{ form1datacopy.userName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="上报人电话：">
              {{ form1datacopy.phone }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="提升方案：">
              <div v-show="uploadList.length>0" v-for="item in uploadList" :key='item'>
                <a @click="downloadFile(form1datacopy.reportId,item)">{{ item.fileName }}</a>
              </div>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem>
              <Button class='ivu-btn-save' @click="model2=false">关闭</Button>
            </FormItem>
          </Col>
        </Row>
      </Form>
    </Modal>

    <Modal title="审计任务选择" :transfer=false footer-hide v-model="missionSelectModal" :width=900>
      <missionSelect ref="selMission" @selectMission="selectMission">
      </missionSelect>
    </Modal>
    <flow-chart ref="flowChart"/>
    <audit-submit ref="auditSubmit" title="完善提升方案流程上报" :data="obj" @success="auditSubmitSuccess"/>
  </Layout>
</template>

<script>
import {Api} from '../../../api/index.js'
import {sessionStorage} from '../../../common/cacheUtils.js';
import cascaderDom from '../../../components/cascader-dom.vue';
import missionSelect from "./missionSelectAuidt.vue"
import flowChart from "@/views/base/task/flowChart";
import auditSubmit from "@/views/safe/audit/auditSubmit";

export default {
  components: {
    cascaderDom, missionSelect, flowChart, auditSubmit
  },
  data() {
    return {
      obj: {},
      buttonLoading1: false,
      groupLeaderList: [],
      history: [],
      loading2: false,
      model3: false,
      missionList: [],
      fileUrl: Api.interestedPartiesUserFile,
      currentUser: sessionStorage('userId').getObject('userId'),
      missionSelectModal: false,
      upLoadList1: [],
      appStatusList: [],
      locationList: [],
      stdRankList: [],
      downloadUrl: Api.downloadMongoFile,
      upUrl: Api.uploadMongoFile,
      form1: {},
      uploadList: [],
      pageSizeArray: [10, 20, 50],
      pagedata: {
        total: 0,
        pageSize: 10,
        currentPage: 1,
      },
      dataTable: [],
      columns1: [
        {
          title: "序号",
          width: 80,
          align: "center",
          fixed: 'left',
          render: (h, params) => {
            return h('span', params.index + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
          }
        },
        {
          title: "审批状态",
          width: 100,
          align: "center",
          fixed: 'right',
          render: (h, params) => {
            return h('div', [
              h('span', {
                style: {
                  color: params.row.procinstState == '0' ? 'red' : params.row.procinstState == 1 ? 'green' : params.row.procinstState == 2 ? 'orange' : params.row.procinstState == 3 ? 'blue' : 'red'
                },
              }, params.row.procinstState == '0' ? '未上报' : params.row.procinstState == 1 ? '审批中' : params.row.procinstState == 2 ? '被退回' : params.row.procinstState == 3 ? '审批完成' : '未上报' || '未上报')
            ]);
          }
        },
        {
          title: '被审计单位',
          minWidth: 300,
          align: 'center',
          key: 'auditOrgName',
        },
        {
          title: '概述',
          minWidth: 300,
          align: 'center',
          key: 'desc',
          ellipsis: 'true',
        },
        {
          title: '上报人',
          minWidth: 150,
          align: 'center',
          key: 'userName',
        },
        {
          title: '上报人电话',
          minWidth: 150,
          align: 'center',
          key: 'phone',
        },

        {
          title: '操作',
          key: 'action',
          fixed: 'right',
          width: 210,
          align: 'center',
          render: (h, params) => {
            if (params.row.procinstState) {
              return h('div', [
                h('A', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    fontSize: '14px'
                  },
                  on: {
                    click: () => {
                      this.showData(params, 1);
                    }
                  }
                }, '详情'),
                h('Divider', {
                  props: {
                    type: 'vertical',
                  }
                }, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px', color: '#c5c8ce', pointerEvents: 'none'},
                }, '上报'),
                h('Divider', {
                  props: {
                    type: 'vertical',
                  }
                }, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px', color: '#c5c8ce', pointerEvents: 'none'},
                }, '修改'),
                h('Divider', {
                  props: {
                    type: 'vertical',
                  }
                }, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px', color: '#c5c8ce', pointerEvents: 'none'},
                }, '删除'),
                h('a', {
                  props: {
                    type: 'primary',
                  },
                  style: {
                    fontSize: '14px',
                    color: params.row.procinstId == null ? '#d0d0d0' : '',
                    pointerEvents: params.row.procinstId == null ? 'none' : ''
                  },
                  on: {
                    click: () => {
                      this.$refs.flowChart.showHistory(params.row.procinstId);
                    }
                  }
                }, '审批记录')
              ]);
            }
            if (this.currentUser.loginId === this.Common.admin || this.currentUser.userId === params.row.createUserId || this.currentUser.userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined) {
              return h('div', [
                h('A', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    fontSize: '14px'
                  },
                  on: {
                    click: () => {
                      this.showData(params, 1);
                    }
                  }
                }, '详情'),
                h('Divider', {
                  props: {
                    type: 'vertical',
                  }
                }, ''),
                h('A', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    fontSize: '14px',
                    color: params.row.procinstId ? '#d0d0d0' : '',
                    pointerEvents: params.row.procinstId ? 'none' : ''
                  },
                  on: {
                    click: () => {
                      this.obj = {
                        workId: params.row.id,
                        key: "promotionPlan",
                        formKey: "promotionPlanForApproval",
                      };
                      this.$refs["auditSubmit"].showAudit()
                    }
                  }
                }, '上报'),
                h('Divider', {
                  props: {
                    type: 'vertical',
                  }
                }, ''),
                h('A', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    fontSize: '14px',
                  },
                  on: {
                    click: () => {
                      this.showData(params, 2);
                    }
                  }
                }, '修改'),
                h('Divider', {
                  props: {
                    type: 'vertical',
                  }
                }, ''),
                h('A', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    fontSize: '14px',
                    color: 'red',
                  },
                  on: {
                    click: () => {
                      this.$Modal.confirm({
                        title: '提示',
                        content: '<p>是否要删除？</p>',
                        onOk: () => {
                          this.deleteData(params);
                        },
                        onCancel: () => {

                        }
                      });
                    }
                  }
                }, '删除'),
                h('a', {
                  props: {
                    type: 'primary',
                  },
                  style: {
                    fontSize: '14px',
                    color: params.row.procinstId == null ? '#d0d0d0' : '',
                    pointerEvents: params.row.procinstId == null ? 'none' : ''
                  },
                  on: {
                    click: () => {
                      this.$refs.flowChart.showHistory(params.row.procinstId);
                    }
                  }
                }, '审批记录')
              ]);
            }else{
              return h('div', [
                h('A', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    fontSize: '14px'
                  },
                  on: {
                    click: () => {
                      this.showData(params, 1);
                    }
                  }
                }, '详情'),
                h('Divider', {
                  props: {
                    type: 'vertical',
                  }
                }, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px', color: '#c5c8ce', pointerEvents: 'none'},
                }, '上报'),
                h('Divider', {
                  props: {
                    type: 'vertical',
                  }
                }, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px', color: '#c5c8ce', pointerEvents: 'none'},
                }, '修改'),
                h('Divider', {
                  props: {
                    type: 'vertical',
                  }
                }, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px', color: '#c5c8ce', pointerEvents: 'none'},
                }, '删除'),
                h('a', {
                  props: {
                    type: 'primary',
                  },
                  style: {
                    fontSize: '14px',
                    color: params.row.procinstId == null ? '#d0d0d0' : '',
                    pointerEvents: params.row.procinstId == null ? 'none' : ''
                  },
                  on: {
                    click: () => {
                      this.$refs.flowChart.showHistory(params.row.procinstId);
                    }
                  }
                }, '审批记录')
              ]);
            }

          }
        },
      ],
      ruleCustom: {
        missionId: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.missionId == undefined || this.form1datacopy.missionId == null || this.form1datacopy.missionId == '') {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        phone: [{
          validator: (rule, value, callback) => {
            if (!(/^1[3456789]\d{9}$/.test(this.form1datacopy.phone))) {
              callback(' ');
              // this.$Message.error("请填写有效的的手机号")
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'blur'
        }],

      },
      auditLeaderList: [],
      auditedOrgName: '',
      auditedOrgId: '',
      add: false,
      model1: false,
      model2: false,
      showdata: {},
      location: null,
      form1datacopy: {},
      files: [],
      buttonLoading: false,
      tableHeight: 10,
    }
  },
  mounted() {
    this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
    this.query();
  },
  methods: {
    auditSubmitSuccess() {
      this.query();
    },
    showHistory(row) {
      this.model3 = true;
      this.loading2 = true;
      this.$http.get(Api.getHistory + '/' + row.procinstId, {params: {}}).then((res) => {
        this.history = res.data;
        this.loading2 = false;
      }).catch(e => {
        this.$Message.error("数据获取失败")
      })
    },
    downloadFile(guideId, file) {
      let url = this.fileUrl + '/file/' + file.id;
      this.$http.get(url, {
        responseType: 'blob'      //告诉服务器我们需要的响应格式
      }).then((res) => {
        console.log(res)
        const aLink = document.createElement("a");
        let blob = new Blob([res.data], {
          type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
        });
        aLink.href = URL.createObjectURL(blob)
        aLink.download = file.fileName //标题
        aLink.click()
        document.body.appendChild(aLink)
      })
    },
    remove1(id) {
      console.log(id)
      let url = this.fileUrl + '/file/' + id;
      this.$http.delete(url).then((res) => {
        this.getFiles()
      })
    },

    beforeUpload(file) {
      let formData = new FormData();
      formData.append("files", file); // 文件对象
      let url = this.fileUrl + '/' + this.form1datacopy.id + '/files/adtReport'
      this.$http.post(url, formData).then((res) => {
        if (res.data.result == "success") {
          this.$Message.info("文件上传成功")
          this.getFiles();
        }
      })
      return false
    },
    async getFiles() {
      let url = this.fileUrl + '/' + this.form1datacopy.id + '/files/adtReport'
      await this.$http.get(url).then((res) => {
        if (res.data.result == "success") {
          this.uploadList = res.data.data
          console.log(this.uploadList);
        }
      })
    },
    setOrgId(data) {
      this.form1.orgId = data[data.length - 1];
    },
    downloadTemplate(){
      this.$http.get(Api.downloadadtReport, {
        responseType: 'blob'      //告诉服务器我们需要的响应格式
      }).then((res) => {
        const aLink = document.createElement("a");
        let blob = new Blob([res.data], {
          type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
        });
        aLink.href = URL.createObjectURL(blob)
        aLink.download = "安全审计报告模板-2021.docx" //标题
        aLink.click()
        document.body.appendChild(aLink)
      })
    },
    setOrgName(data) {
      this.form1.auditOrgName = data;
    },
    reportInfo(row) {
      let user = sessionStorage('userId').getObject('userId');
      let istrue = confirm("是否上报该条记录？");
      if (istrue) {
        this.buttonLoading = true;
        let data = {
          key: "adtReport",
          createUserId: user.userId,
          userName: user.userName,
          workId: row.reportId,
          formKey: "adtReportForApproval",
          user1: row.supervisorId,
          user2: row.groupLeader,
          user3: row.auditLeader,
        };
        this.$http.post(Api.submit, data).then(function (res) {
          this.buttonLoading = false;
          this.$Message.success({
            content: '保存成功',
            duration: 4
          });
          this.query();
        }, function (err) {
          this.buttonLoading = false;
          this.$Message.error({
            content: '保存失败',
            duration: 4
          });
        });
      }

    },
    onCancel() {
      this.model2 = false
    },
    closeModal1() {
      this.expertSelectModal = false;
    },
    selectMission(row) {
      this.missionSelectModal = false;
      this.form1datacopy.missionName = row.missionName;
      this.form1datacopy.missionId = row.missionId;
      this.form1datacopy.auditTypeName = row.auditTypeName;
      this.form1datacopy.groupLeaderName = row.groupLeaderName;
      this.form1datacopy.auditOrgName = row.auditedOrgName;
      this.form1datacopy.supervisor = row.supervisor;
      this.form1datacopy.planStart = this.formatDate(new Date(row.planStart), 'yyyy-MM-dd');
      this.form1datacopy.planEnd = this.formatDate(new Date(row.planEnd), 'yyyy-MM-dd');


    },
    deleteFile(index) {
      this.files.splice(index, 1);
    },
    deleteData(params) {
      let url = Api.deleteAuditPromotionPlan;
      this.$http.delete(url + "/" +params.row.id).then((res) => {
        if (res.status === 200) {
          this.$Message.success('成功');
          this.query()
        } else if (res.data.status === 201) {
          this.$Message.error(res.data.msg);

        }
      }).catch(e => {
        this.$Message.error('请求失败' + e);
      })
    },

    openSelect() {
      this.missionSelectModal = true
    },
    addInfo() {
      this.form1datacopy = {
        id: this.get_uuid(),
        userName:this.currentUser.userName

      };

      this.uploadList = [];
      this.model1 = true;
      this.add = true;
    },
    pageChange(pageNum) {
      this.pagedata.currentPage = pageNum;
      this.query();
    },
    pageSizeChange(pageSize) {
      this.pagedata.pageSize = pageSize;
      this.query();
    },
    handleCancel() {
      this.form1datacopy = {};
      this.model1 = false;
    },
    selectCodingSort() {

    },
    reset() {
      // this.$refs.trainOrg.resetCurrentOrg();
      this.form1 = {};
      this.query();


    },
    setUserId(data) {
      this.form1datacopy.projectManager = data[data.length - 1];
    },
    setUserName(data) {
      this.form1datacopy.projectManagerName = data;
    },

    setUserId1(data) {
      this.form1datacopy.groupLeader = data[data.length - 1];
    },
    setUserName1(data) {
      this.form1datacopy.userName = data;
    },

    query() {
      this.buttonLoading = true
      let userId = JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"]
      let orgId = sessionStorage('userId').getObject('userId').companyId;
      let data = {
        startPage: this.pagedata.currentPage,
        size: this.pagedata.pageSize,
      };
      data = Object.assign(data, JSON.parse(JSON.stringify(this.form1)));
      data.missionName = this.form1.missionName || ''
      let url = Api.queryAuditPromotionPlan;

      this.$http.get(url, {params: data}).then((res) => {

        this.dataTable = res.data.data.data;
        this.pagedata.total = res.data.data.totalSize;
        this.buttonLoading = false
      }).catch(e => {
        this.$Message.error("数据获取失败")
      })
    },
    async showData(data, flag) {

      this.auditOrgId = data.row.auditedOrgId;
      this.auditOrgName = data.row.auditedOrgName;
      if (flag == 1) {
        //查看页面
        this.form1datacopy = data.row;
        await this.getFiles()
        this.model2 = true;
      } else {
        this.add = false;
        this.form1datacopy = JSON.parse(JSON.stringify(data.row));
        await this.getFiles()
        this.model1 = true;
      }

    },
    formatDate(date, fmt) {
      if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
      }
      let o = {
        'M+': date.getMonth() + 1,
        'd+': date.getDate(),
        'h+': date.getHours(),
        'm+': date.getMinutes(),
        's+': date.getSeconds()
      };
      for (let k in o) {
        if (new RegExp(`(${k})`).test(fmt)) {
          let str = o[k] + '';
          fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
        }
      }
      return fmt;
    },

    submit(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          //this.form1datacopy.planStart = this.formatDate(new Date(this.form1datacopy.planStart), 'yyyy-MM-dd');
          //this.form1datacopy.planEnd = this.formatDate(new Date(this.form1datacopy.planEnd), 'yyyy-MM-dd');
          this.buttonLoading1 = true;
          if (this.add) {
            let userId = sessionStorage('userId').getObject('userId').userId;
            let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
            this.form1datacopy.createUserId = userId;
            this.form1datacopy.createOrgId = orgId;

            this.$http.post(Api.saveAuditPromotionPlan, this.form1datacopy).then((res) => {
              this.buttonLoading1 = false;
              if (res.status === 200) {
                this.$Message.success('成功');
                this.model1 = false;
                this.query()

              } else if (res.data.status === 201) {
                this.$Message.error(res.data.msg);
                this.model1 = false;
              }

            }).catch(e => {
              this.buttonLoading1 = false;
              this.model1 = false;
              this.query();
              this.$Message.error("数据获取失败")
            })
          } else {
            let userId = sessionStorage('userId').getObject('userId').userId;
            let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
            this.form1datacopy.updateUserId = userId;
            this.form1datacopy.updateOrgId = orgId;
            this.$http.put(Api.updateAuditPromotionPlan, this.form1datacopy).then((res) => {
              this.buttonLoading1 = false;
              if (res.status === 200) {
                this.$Message.success('成功');
                this.model1 = false;
                this.query()

              } else if (res.data.status === 201) {
                this.$Message.error(res.data.msg);
                this.model1 = false;
              }

            }).catch(e => {
              this.buttonLoading1 = false;
              this.model1 = false;
              this.query();
              this.$Message.error("数据获取失败")
            })
          }


        } else {
          this.$Message.error('请填报完整!');
        }
      })
    },
    padLeftZero(str) {
      return ('00' + str).substr(str.length);
    },
    get_uuid() {
      let s = [];
      let hexDigits = "0123456789abcdef";
      for (let i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
      }
      s[14] = "4";
      s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
      s[8] = s[13] = s[18] = s[23] = "-";

      let uuid = s.join("");
      let reg = new RegExp("-", "g");
      let a = uuid.replace(reg, "");
      console.log(a);
      return a;
    },
  },
  watch: {
    "model1": function (qw, er) {
      if (qw && this.model1) {
        setTimeout(() => {
          this.$refs.childUser.setCurrentOrg();
          this.$refs.childUser1.setCurrentOrg();
        }, 100)
      } else {
        this.$refs.childUser.resetCurrentOrg();
        this.$refs.childUser1.resetCurrentOrg();
      }
    },

  },
}
</script>

<style lang='css' scoped>
@import '../../../index.css';
</style>
